package com.google.project.server.entity;

import java.io.Serializable;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.project.shared.ProjectStaffDTO;

@SuppressWarnings("serial")
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class ProjectStaff implements Serializable{
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	@Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
	private String id;
	@Persistent
	private String userId;
	@Persistent
	private String userName;
	@Persistent
	private String fullName;
	@Persistent
	private String userCode;
	@Persistent
	private int position;
	@Persistent
	private Long startDate;
	@Persistent
	private Long finishDate;
	@Persistent
	private String specializeID;
	@Persistent
	private String specializeName;
	@Persistent
	private int experient;
	@Persistent
	private int status;
	@Persistent
	private String projectId;
	@Persistent
	private Project project;
	@Persistent
	private String taskId;
	
	public ProjectStaff() {
	}

	public ProjectStaff(ProjectStaffDTO projectStaffDTO){
		this.userId = projectStaffDTO.getUserId();
		this.userName = projectStaffDTO.getUserName();
		this.fullName=projectStaffDTO.getFullName();
		this.userCode = projectStaffDTO.getUserCode();
		this.position = projectStaffDTO.getPosition();
		this.startDate = projectStaffDTO.getStartDate();
		this.finishDate = projectStaffDTO.getFinishtDate();
		this.specializeID = projectStaffDTO.getSpecializeID();
		this.specializeName = projectStaffDTO.getSpecializeName();
		this.experient = projectStaffDTO.getExperient();
		this.status = projectStaffDTO.getStatus();
		this.projectId = projectStaffDTO.getProjectId();
		this.taskId=projectStaffDTO.getTaskId();
	}
	
	public ProjectStaffDTO toDTO() {
		ProjectStaffDTO data = new ProjectStaffDTO();
		data.setId(id);
		data.setUserId(userId);
		data.setUserName(userName);
		data.setFullName(fullName);
		data.setUserCode(userCode);
		data.setPosition(position);
		data.setStartDate(startDate);
		data.setFinishtDate(finishDate);
		data.setSpecializeID(specializeID);
		data.setSpecializeName(specializeName);
		data.setExperient(experient);
		data.setStatus(status);
		data.setProjectId(projectId);
		data.setTaskId(taskId);
		return data;
	}
	
	
	/*
	 * Update function
	 */
	public void updateFromDTO(ProjectStaffDTO projectStaffDTO){
		this.userId = projectStaffDTO.getUserId();
		this.userName = projectStaffDTO.getUserName();
		this.fullName=projectStaffDTO.getFullName();
		this.userCode = projectStaffDTO.getUserCode();
		this.position = projectStaffDTO.getPosition();
		this.startDate = projectStaffDTO.getStartDate();
		this.finishDate = projectStaffDTO.getFinishtDate();
		this.specializeID = projectStaffDTO.getSpecializeID();
		this.specializeName = projectStaffDTO.getSpecializeName();
		this.experient = projectStaffDTO.getExperient();
		this.status = projectStaffDTO.getStatus();
		this.projectId = projectStaffDTO.getProjectId();
		this.taskId=projectStaffDTO.getTaskId();
	}
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public int getPosition() {
		return position;
	}
	public void setPosition(int position) {
		this.position = position;
	}
	public Long getStartDate() {
		return startDate;
	}
	public void setStartDate(Long startDate) {
		this.startDate = startDate;
	}
	
	public Long getFinishDate() {
		return finishDate;
	}

	public void setFinishDate(Long finishDate) {
		this.finishDate = finishDate;
	}

	public String getSpecializeID() {
		return specializeID;
	}

	public void setSpecializeID(String specializeID) {
		this.specializeID = specializeID;
	}

	public String getSpecializeName() {
		return specializeName;
	}

	public void setSpecializeName(String specializeName) {
		this.specializeName = specializeName;
	}

	public int getExperient() {
		return experient;
	}

	public void setExperient(int experient) {
		this.experient = experient;
	}
	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}

	public String getProjectId() {
		return projectId;
	}

	public void setProjectId(String projectId) {
		this.projectId = projectId;
	}

	public Project getProject() {
		return project;
	}

	public void setProject(Project project) {
		this.project = project;
	}

	public String getUserCode() {
		return userCode;
	}

	public void setUserCode(String userCode) {
		this.userCode = userCode;
	}

	public String getFullName() {
		return fullName;
	}

	public void setFullName(String fullName) {
		this.fullName = fullName;
	}

	public String getTaskId() {
		return taskId;
	}

	public void setTaskId(String taskId) {
		this.taskId = taskId;
	}
	
}
